<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ include file="/WEB-INF/component/commonTagLib.jsp"%>
<!DOCTYPE html>
<html>
<head>
    <title><spring:message code="message.listForm.DingDanQueRen"/></title>
    <%@ include file="/WEB-INF/component/commonCSS.jsp"%>
</head>

<body class="skin-blue-light sidebar-mini fixed skin-blue-light-frame">

    <section class="content-header">
        <h1>审核未通过订单</h1>
        <ol class="breadcrumb">
        	<li><a href="${ctx}/home.jsp"><i class="fa fa-home"></i><spring:message code="message.lable.first"/></a></li>
        	<li><a href="#">交易</a></li>
        	<li><a href="#"><spring:message code="message.list.DingDanGuanLi"/></a></li>
            <li><a href="#">审核未通过订单</a></li>
           <%--  <li class="active"><a href="#"><spring:message code="message.list.WeiWanChengDingDan"/></a></li>  --%>
        </ol>
    </section>
    
    <section class="content">
        <div class=" box box-success">
            <div class="box-body">
                <div class="input" style="margin-top:-5px;">
                    <div class="textalign1">配送企业名称<spring:message code="message.yanZheng.maoHao"/></div>
                    <div class="boxinput">
                        <input type="text" class="textinput" id="delCompName" name="delCompName" placeholder="配送企业名称/<spring:message code="message.listForm.pinYinMa"/>" />
                    </div>
                <div class="textalign1"><spring:message code="message.listForm.DingDanBaoHao"/><spring:message code="message.yanZheng.maoHao"/></div>
                    <div class="boxinput">
                        <input type="text" class="textinput" id="orderPackId" name="orderPackId" placeholder="<spring:message code="message.listForm.DingDanBaoHao"/>" />
                    </div>
                    <div class="textalign1"><spring:message code="message.listForm.CaiGouRiQi"/><spring:message code="message.yanZheng.maoHao"/></div>
                    <div class="boxinput"> 
                       <table style="width:100%">
                                <tr>
                                    <td style="width:50%">
                                        <input id="startDate" name="startDate" type="text" class="textinput" placeholder="yyyy-MM-dd" 
                                            data-date-fmt="yyyy-MM-dd" onFocus="WdatePicker({maxDate:'#F{$dp.$D(\'endDate\')}'})" />
                                    </td>
                                    <td>&nbsp;-&nbsp;</td>
                                    <td style="width:50%">
                                        <input id="endDate" name="endDate" type="text" class="textinput"  placeholder="yyyy-MM-dd" 
                                        data-date-fmt="yyyy-MM-dd" onFocus="WdatePicker({minDate:'#F{$dp.$D(\'startDate\')}'})" /> 
                                    </td> 
                                </tr>
                            </table>
                    </div>
                      
                    <div class="textalign1" >
                    <button type="button" class="btn btn-success btn-sm" onclick="search()" id="selectDicCompType"><spring:message code="message.button.seachSpacing"/></button>
                    </div> 
                  </div> 
            </div>
        </div>
        
        <table class="jqgrid" id="gridlist"></table>
         <div id="gridpage"></div>
        <div class=" box box-warning bottongroup">
	        
            <button type="button" onclick="toSubmit();" class="btn btn-primary btn-sm"><spring:message code="message.button.TiJiaoDingDan"/></button>
            <button type="button" onclick="removeDel();" class="btn btn-danger btn-sm"><spring:message code="message.button.delete"/></button>
            </div>
    </section>
    
    <%@ include file="/WEB-INF/component/commonJS.jsp"%>
    <script type="text/javascript">
        function showOrderDetail(orderPackId,amount) {
            $.HN.dialog.open({
                "id" : "orderDetail",
                width:"1000px",
                height:"550px",
                "title" : "未通过审核订单明细",
                "url" : "${ctx}/noOrderConfirm/toPurOrderNotConfirmDteail.html?amount="+ amount +"&orderPackId=" + orderPackId
            });
        }
        
        function orderDetailLink(orderPackId,amount, text) {
            return "<a href='javascript:showOrderDetail(\"" + orderPackId + "\",\""+ amount +"\")' style='background:url(${ctx}/lib/img/icon/icon.png) no-repeat -100px 0px' class='opIcon' title='" + text + "'></a>";
        }
    
        $(function () {
            //绑定回车
            $('#orderPackId,#startDate,#endDate,#delCompName').bind('keydown', function(event) {
                if (event.keyCode == "13") {
                    $('#selectDicCompType').click();
                }
            }); 
            
            $("#delCompName").focus();//加载页面光标在第一个查询框内
            
            $("#gridlist").jqGrid({
                url: "getNotPassOrderList.html",
                mtype: "POST",
                datatype: "json",
                shrinkToFit: false,
                autowidth: true,
              //  height: 300,
                colNames: [
                    '操作',
                    '订单状态',
                    '<spring:message code="message.listForm.DingDanBaoHao"/>', 
                    '配送企业',
                    '<spring:message code="message.listForm.CaiGouShiJian"/>',
                    '<spring:message code="message.listForm.TiaoMuShu"/>', 
                    '<spring:message code="message.listForm.ZongJinE"/>',
                    '<spring:message code="message.listForm.JiaJiDingDan"/>',
                    '收货人',
                    '收货人电话',
                    '送货地址',
                    '<spring:message code="message.lable.hospRemark"/>'
                ],
                colModel: [
                    { name: 'operate', width: 60 , align:"center" ,sortable: false,
                        formatter:function(cellvalue, options, row){
                            return orderDetailLink(row.orderPackId,row.amount, '编辑');
                        }
                    },
                    { name: 'orderStatus', width: 100 , align:"center" ,sortable: false},
                    { name: 'orderPackId', width: 180 , align:"center" ,sortable: false },
                    { name: 'delCompName', width: 250 , align:"center" ,sortable: false/* ,
                    	formatter:function(cellvalue, options, row){
                            return compInfoLink(row.delCompCode,row.delCompName, 1);
                        } */
                    },
                    { name: 'submitDatetime', width: 160 , align:"center" ,sortable: false},
                    { name: 'count', width: 80 , align:"center",sortable: false},
                    { name: 'amount', width: 80 , align:"right",sortable: false},
                    { name: 'isUrgent', width: 80 , align:"center",sortable: false},
                    { name: 'recpUser', width: 100 , align:"center" ,sortable: false },
                    { name: 'recpUserphone', width: 120 , align:"center" ,sortable: false },
                    { name: 'recpAddr', width: 300 , align:"left" ,sortable: false },
                    { name: 'remarks', width: 250 , align:"left" ,sortable: false }
                ],
                rowNum: 20,
                rowList: [10, 20, 50, 100],
                rownumbers: true,
                multiselect: true,
                pager: "#gridpage",
                viewrecords: true,
                gridComplete:function(){
                    //序号列宽度自适应（参数为jqgridID）
                    autoRNWidth("gridlist");
                    //数据只有一条时默认选中（参数为jqgridID）
                    selectByOneData("gridlist");
                },
                caption: "未完成订单列表",
                jsonReader: {
                    repeatitems: false,
                    id: "orderPackId"
                }
            });
            $("#gridlist").jqGrid('navGrid', '#gridpage', { add: false, edit: false, del: false, search: false, refresh: false });
            $(window).trigger("resize");
            $("#gridlist").jqGrid("setGridHeight", create());
            
        });
        
        
        /* 查询 */
        function search() {
            var orderPackId = $.trim($("#orderPackId").val());
            var delCompName = $.trim($("#delCompName").val());
            var startDate = $("#startDate").val();
            var endDate = $("#endDate").val();
            $("#gridlist").jqGrid("clearGridData");
                $("#gridlist").jqGrid('setGridParam',{  
                mtype: "POST",
                datatype:'json',
                postData:{
                    "orderPackId":orderPackId,
                    "startDate":startDate,
                    "endDate":endDate,
                    "delCompName":delCompName,                   
                },
                page : 1
            }).trigger("reloadGrid"); //重新载入  
        }
        //删除
        function removeDel(){
		    var rowIds = $("#gridlist").jqGrid("getGridParam", "selarrrow") || [];
			if (rowIds.length <= 0) {
				$.HN.message.alert("请选择要刪除的订单！", "<spring:message code="message.HN.alert.type"/>", "warn");
				return;
			}			
			$.HN.message.confirm('确定删除以下订单吗？<br/>', '', '').on(function (e) {
    			if (e) {
					var list = [];
					for (var i=0; i<rowIds.length; i++) {
						rowId = rowIds[i];
						var rowdata = $("#gridlist").jqGrid('getRowData', rowId);
						list.push({"orderPackId":rowdata.orderPackId});
					}
					$.post("${ctx}/noOrderConfirm/orderDelete.html", {
						"array" : json.jsonToString(list)
						}, function(result) {
							if (result.success) {
								$.HN.message.alert("刪除成功！", "<spring:message code="message.HN.alert.type"/>", "success");
								search();
							} else {
								$.HN.message.alert("删除失败！", "<spring:message code="message.HN.alert.type"/>", "error");
							}
						}, "json")
    			}
    		});
		}
        
        function toSubmit(){        	 
      		    var rowIds = $("#gridlist").jqGrid("getGridParam", "selarrrow") || [];
      			if (rowIds.length <= 0) {
      				$.HN.message.alert("请选择要提交的订单！", "<spring:message code="message.HN.alert.type"/>", "warn");
      				return;
      			}
      			
      			$.HN.message.confirm('确定提交以下订单吗？<br/>', '', '').on(function (e) {
          			if (e) {
      					var list = [];
      					for (var i=0; i<rowIds.length; i++) {
      						rowId = rowIds[i];
      						var rowdata = $("#gridlist").jqGrid('getRowData', rowId);
      						list.push({"orderPackId":rowdata.orderPackId});
      					}
      					$.post("${ctx}/noOrderConfirm/orderSubmit.html", {
      						"array" : json.jsonToString(list)
      						}, function(result) {
      							if (result.success) {
      								$.HN.message.alert("提交成功！", "<spring:message code="message.HN.alert.type"/>", "success");
      								search();
      							} else {
      								$.HN.message.alert("提交失败！", "<spring:message code="message.HN.alert.type"/>", "error");
      							}
      						}, "json")
          			}
          		});
      		}
              
        
    </script>
</body>
</html>